import logging
import os
from datetime import datetime

from pytz import timezone


def get_date_time(time_format="%Y-%m-%d %H:%M:%S"):
    """Получаем текущее время"""

    date_and_time = datetime.now(timezone("Europe/Moscow")).strftime(time_format)
    return date_and_time


def configure_logging():
    logging.getLogger("aiohttp.access").setLevel(logging.WARNING)
    logging.getLogger("aiogram.event").setLevel(logging.WARNING)

    logging.basicConfig(
        filename="{0}/logs/log-{1}.log".format(os.getcwd(), get_date_time("%Y-%m-%d")),
        level=logging.INFO,
        format="%(filename)s:%(lineno)d #%(levelname)-8s [%(asctime)s] - %(name)s - %(message)s",
    )
